package com.leoman.plz_p.presenter;

import com.leoman.plz_p.interfaces.MineView;
import com.leoman.plz_p.module.api.MainApi;
import com.leoman.plz_p.module.bean.BaseData;
import com.leoman.plz_p.module.bean.MapData;
import com.leoman.plz_p.subscriber.ResponseSubscriber;

import cn.com.corelib.api.ResponseTransformer;
import cn.com.corelib.base.BasePresenter;

/**
 * Created by guoh on 2018/8/26.
 */
public class MinePresenter extends BasePresenter<MineView>{

    private MainApi mainApi;

    @Override
    protected void onViewAttach() {
        super.onViewAttach();
        mainApi=getApi(MainApi.class);
    }


    @Override
    public void onStart() {

    }

    public void getAboutUs(){
        mainApi.getAboutUs().compose(new ResponseTransformer<>(this.<BaseData<MapData>>bindToLifeCycle()))
                .subscribe(new ResponseSubscriber<BaseData<MapData>>(view) {
                    @Override
                    public void success(BaseData<MapData> listData) {
                        if (checkDataNotNull(listData))
                            view.obtainAboutUs(listData.data.content);
                    }

                });
    }

    public void getHelp(){
        mainApi.getHelp().compose(new ResponseTransformer<>(this.<BaseData<MapData>>bindToLifeCycle()))
                .subscribe(new ResponseSubscriber<BaseData<MapData>>(view) {
                    @Override
                    public void success(BaseData<MapData> listData) {
                        if (checkDataNotNull(listData))
                            view.obtainHelp(listData.data.content);
                    }

                });
    }

}
